﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace ChatForum.Database
{
    public class SqlServerDatabase : DatabaseBase
    {
        private readonly string connectionStringFormat = "Data Source={0};Initial Catalog={1};User Id={2};Password={3};";
        private string databaseName;

        public SqlServerDatabase(string dataSource, string databaseName, string userId, string password, string startupScriptPath)
            : base(dataSource, userId, password, startupScriptPath)
        {
            this.databaseName = databaseName;
            Setup();
        }

        protected override IDbConnection CreateConnection()
        {
            return new SqlConnection(ConnectionString);
        }

        protected override string ConnectionString
        {
            get { return string.Format(connectionStringFormat, dataSource, databaseName, userId, password); }
        }
    }
}
